package com.bckj.fastboot.core.web.repeat.strategy;

import com.bckj.fastboot.core.util.SpringUtils;
import jakarta.annotation.PostConstruct;
import lombok.RequiredArgsConstructor;

import java.util.HashMap;
import java.util.Map;

@RequiredArgsConstructor
public class RepeatSubmitProvider {

    private final Map<String, RepeatSubmitStrategy> strategyMap = new HashMap<>();

    @PostConstruct
    public void init() {
        Map<String, RepeatSubmitStrategy> types = SpringUtils.getBeanOfType(RepeatSubmitStrategy.class);
        types.forEach((k, v) -> strategyMap.put(v.getType(), v));
    }

    public RepeatSubmitStrategy getStrategy(String type) {
        return strategyMap.get(type);
    }
}
